import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;

public class Main {
    public static String solution(String s) {
        // 分离整数部分和小数部分
        String[] parts = s.split("\\.");
        String integerPart = parts[0];
        String decimalPart = parts.length > 1 ? "." + parts[1] : "";

        // 去除前导零
        integerPart = integerPart.replaceFirst("^0+(?!$)", "");

        // 格式化整数部分
        try {
            long number = Long.parseLong(integerPart);
            NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
            ((DecimalFormat)nf).setGroupingUsed(true);
            ((DecimalFormat)nf).setDecimalSeparatorAlwaysShown(false);

            return nf.format(number) + decimalPart;
        } catch (NumberFormatException e) {
            return "0" + decimalPart;
        }
    }

    public static void main(String[] args) {
        System.out.println(solution("1294512.12412").equals("1,294,512.12412"));
        System.out.println(solution("0000123456789.99").equals("123,456,789.99"));
        System.out.println(solution("987654321").equals("987,654,321"));
        System.out.println(solution("0000").equals("0"));
        System.out.println(solution("0000123").equals("123"));
        System.out.println(solution("0.123").equals("0.123"));
    }
}